import {
  getCustomerList as getSelectCustomerList,
  getDeliveryMethodList as getMesSalesOrderDeliveryMethodList,
  getFactoryCodeList as getMesSalesOrderFactoryCodeList,
  getCustomerTypeNameList,
  getCustomerTypeValueList,
} from "@/api/order/mesSalesOrder";

export const mesCustomerDialog = {
  data() {
    return {
      mesCustomerDialogVisible: false, //表格弹框隐藏显示
      getSelectCustomerList, // 获取弹框数据接口
      hasMesSalesOrderFooter: true, // 是否需要底部按钮默认true
      mesCustomerSearchDialog: {
        inline: true,
        formDesc: {
          customerCode: {
            type: "input",
            layout: 8,
            label: $i18n.t("mesRequirePlan.customerCode"),
          },
          customerName: {
            type: "input",
            layout: 8,
            label: $i18n.t("mesRequirePlan.customerName"),
          },
          customerTypeValue: {
            type: "select",
            label: $i18n.t("mesRequirePlan.customerType"),
            layout: 8,
            prop: {
              value: "value",
              text: "description",
            },
            options: async (data) => {
              const list = await getCustomerTypeValueList();
              return list.data.result;
            },
          },
        },
      },
      mesCustomerDialogColumn: [
        {
          type: "index",
          label: $i18n.t("common.order"),
          fixed: "left",
          width: 60,
        },
        {
          prop: "customerCode",
          label: $i18n.t("mesRequirePlan.customerCode"),
          width: 120,
          fixed: "left",
        },
        {
          prop: "customerName",
          label: $i18n.t("mesRequirePlan.customerName"),
          width: 270,
        },
        {
          prop: "address",
          label: $i18n.t("mesRequirePlan.address"),
          width: 270,
        },
        {
          prop: "contacts",
          label: $i18n.t("mesRequirePlan.contacts"),
          width: 100,
        },
        {
          prop: "mobilePhone",
          label: $i18n.t("mesRequirePlan.mobilePhone"),
          width: 140,
        },
        {
          prop: "telephone",
          label: $i18n.t("mesRequirePlan.telephoneFixed"),
          width: 120,
        },
        {
          prop: "customerTypeValue",
          label: $i18n.t("mesRequirePlan.customerType"),
          width: 120,
          optionProp: {
            value: "value",
            label: "description",
          },
          option: async (data) => {
            const list = await getCustomerTypeValueList();
            return list.data.result;
          },
        },
        // {
        //   prop: "customerTypeName",
        //   label: "客商类别",
        //   width: 120,
        //   optionProp: {
        //     value: "value",
        //     label: "description",
        //   },
        //   option: async (data) => {
        //     const list = await getCustomerTypeNameList()
        //     self.skillCodeList = list.data.result;
        //     return list.data.result;
        //   },
        // },
        // {
        //   prop: "qualityType",
        //   label: "质检状态",
        //   width: 120,
        //   optionProp: {
        //     value: "value",
        //     label: "description",
        //   },
        //   option: async (data) => {
        //     const list = await getQualityTypeList()
        //     return list.data.result
        //   },
        // },
        {
          prop: "factoryCode",
          label: $i18n.t("mesRequirePlan.factoryCode2"),
          width: 120,
        },
        // {
        //   prop: "remark",
        //   label: "备注",
        // },
        {
          prop: "createByName",
          label: $i18n.t("common.createByName"),
          width: 120,
        },
        {
          prop: "createTime",
          label: $i18n.t("common.createTime"),
          width: 200,
        },
        {
          prop: "updateByName",
          label: $i18n.t("common.updateByName"),
          width: 130,
        },
        {
          prop: "updateTime",
          label: $i18n.t("common.updateTime"),
          width: 200,
        },
      ],
    };
  },
  methods: {
    getSelectCustomer(data) {
      console.log(12, this.customerType);
      if (this.customerType == "add") {
        this.$set(this.formDataDialog, "customerCode", data[0].customerCode);
        this.$set(this.formDataDialog, "customerName", data[0].customerName);
      } else {
        this.$set(
          this.editFormDataDialog,
          "customerCode",
          data[0].customerCode
        );
        this.$set(
          this.editFormDataDialog,
          "customerName",
          data[0].customerName
        );
      }
    },
  },
};
